# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

import requests


class MztDemoPipeline(object):
    def process_item(self, item, spider):
        print ("pipeline works !!!!!!")
        print (item)
        header = {
            'USER-Agent': 'User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
            'Cookie': 'Hm_lvt_dbc355aef238b6c32b43eacbbf161c3c=1543676671; Hm_lpvt_dbc355aef238b6c32b43eacbbf161c3c=1544361413',
            # 需要查看图片的cookie信息，否则下载的图片无法查看
        }
        with open("f:\\mzt\\%s" % item['current'], "wb") as f:
            print (u"只在 %s", item['current'])
            req = requests.get(item['img_url'], headers=header)
            f.write(req.content)

        return item
